package com.birdboot.controller;

import com.birdboot.core.DispatcherServlet;
import com.birdboot.http.HttpServletRequest;
import com.birdboot.http.HttpServletResponse;

import java.io.File;
import java.net.URISyntaxException;

/**
 *  V13新增内容
 *  处理用户相关业务的类
 */
public class UserController {

    public void reg(HttpServletRequest request, HttpServletResponse response){
        //1通过request获取表单数据
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        String nickname = request.getParameter("nickname");
        String ageStr = request.getParameter("age");
        System.out.println(username+","+password+","+nickname+","+ageStr);
        //必要的验证
        if(username==null||username.isEmpty()||
           password==null||password.isEmpty()||
           nickname==null||nickname.isEmpty()||
           ageStr==null||ageStr.isEmpty()||
           !ageStr.matches("[0-9]+")){
            //跳转注册失败页面
            response.sendRedirect("/reg_info_error.html");
            return;
        }else {
            response.sendRedirect("/reg_success.html");
        }

    }
}
